import React from 'react';
import { Text, View } from 'react-native';

import ScrollableTabView from 'react-native-scrollable-tab-view';
import CustormerBar from "./components/CustormerBar";
import FollowEach from "./followEach";
import FollowMe from "./followMe";
import Ifollow from "./Ifollow";
import { MY_LIKELIST } from "../../../utils/pathMap";
import request from "../../../utils/request";

class Index extends React.Component {
    state = {
        // 互相关注
        likeeachlist: [],
        // 喜欢
        ilikelist: [],
        // 粉丝
        likemelist: []
    }

    componentDidMount() {
        this.getList()
    }

    // 获取喜欢相关的数据
    getList = async () => {
        const res = await request.privateGet(MY_LIKELIST)
        // console.log(res);
        const likeeachlist = res.data.likeeachlist
        const ilikelist = res.data.ilikelist
        const likemelist = res.data.likemelist
        this.setState({ likeeachlist, ilikelist, likemelist });
    }

    render() {
        const { likeeachlist, ilikelist, likemelist } = this.state
        const index = this.props.route.params || 0
        return <ScrollableTabView
            initialPage={index}
            renderTabBar={() => <CustormerBar />}
        >
            <FollowEach getList={this.getList} likeeachlist={likeeachlist} tabLabel='互相关注'>
            </FollowEach>
            <Ifollow getList={this.getList} ilikelist={ilikelist} tabLabel='喜欢'>
            </Ifollow>
            <FollowMe getList={this.getList} likemelist={likemelist} tabLabel='粉丝'>
            </FollowMe>
        </ScrollableTabView>
    }
}

export default Index;